// Store object infos
var page = require("page");
function Parameter(OLDC_Object) {
    this.photo = OLDC_Object.photo;
    this.iconId = OLDC_Object.iconId;
    this.iconName = OLDC_Object.iconName;
    this.angle = OLDC_Object.angle;
    this.zoomRatio = OLDC_Object.zoomRatio;
    this.height = OLDC_Object.height;
    this.width = OLDC_Object.width;
    this.theight = OLDC_Object.theight;
    this.twidth = OLDC_Object.twidth;
    this.X = OLDC_Object.X;
    this.Y = OLDC_Object.Y;
    this.currentX = OLDC_Object.currentX;
    this.currentY = OLDC_Object.currentY;
    this.iconX = OLDC_Object.iconX;
    this.iconY = OLDC_Object.iconY;
    this.iconZoomRatio = OLDC_Object.iconZoomRatio;
    this.center = OLDC_Object.center;
    this.left_x = OLDC_Object.left_x;
    this.left_y = OLDC_Object.left_y;
    this.right_x = OLDC_Object.right_x;
    this.right_y = OLDC_Object.right_y;
    this.memo = OLDC_Object.memo;
}

function OLDC_Object() {
    this.iconId = null;
    this.parameterId = null;
    this.iconName = null;
    this.photo = null;
    this.object = null;
    this.angle = 0;
    this.zoomRatio = 1;
    this.height = 0;
    this.width = 0;
    this.theight = 0;
    this.twidth = 0;
    this.X = 0;
    this.Y = 0;
    this.currentX;
    this.currentY;
    this.iconX = 0;
    this.iconY = 0;
    this.iconZoomRatio = 0;
    this.center = new Array();
    this.isAClone = false;
    this.left_x;
    this.left_y;
    this.right_x;
    this.right_y;
    this.memo;
    this.cloneCount = 0;

    this.setObject = function (object) {
        this.object = object;
    }

}

/*
List of OLDC_Object instances
*/
function OLDC_SvgCanvas() {
    this.length = 0;
    this.list = new Array();
    this.svg = null;
    this.selectedObjectID = null;
    this.hasFocusedObject = false;
    this.selectedMenuObject = false;
    this.addLineObject = function (object, lineType) {
        var objectID = this.addObject(object, '_Line');
        this.list[objectID].isAClone = true;
        this.list[objectID].iconName = lineType;
        return objectID;
    };

    // Add an SVG object to the canvas
    this.addObject = function (object, prefix) {
        var objectID = 'OLDC_Object' + (prefix ? prefix : '') + this.length;
        this.list[objectID] = new OLDC_Object();
        this.list[objectID].setObject(object);

        var bbox = object.getBBox();
        this.list[objectID].width = bbox.width;
        this.list[objectID].height = bbox.height;

        // Set the class and id for use with jcl behaviours
        this.setObjectAttribute(objectID, "id", objectID);

        this.length++;
        object.ontouchstart = function (event) {
            touchStart(event);
        }
        object.ontouchmove = function (event) {
            touchMove(event);
        }
        object.ontouchend = function (event) {
            touchEnd(event);
        }
        object.ongesturestart = function (event) {
            gestureStart(event);
        }
        object.ongesturechange = function (event) {
            gestureChange(event);
        }
        object.ongestureend = function (event) {
            gestureEnd(event);
        }
        object.ondblclick = function (event) {
            mousedblclick_listener(event);
        }

        return objectID;
    }

    // Export XML SVG content
    this.toSVG = function () {
        return this.svg.toSVG();
    }

    // from SVG Edit project
    // Matrix multiplication function
    this.matrixMultiply = function () {
        var NEAR_ZERO = 1e-14,
            multi2 = function (m1, m2, svg) {
                var svgroot = svg.root();
                var m = svg.root().createSVGMatrix();
                m.a = m1.a * m2.a + m1.c * m2.b;
                m.b = m1.b * m2.a + m1.d * m2.b,
                    m.c = m1.a * m2.c + m1.c * m2.d,
                    m.d = m1.b * m2.c + m1.d * m2.d,
                    m.e = m1.a * m2.e + m1.c * m2.f + m1.e,
                    m.f = m1.b * m2.e + m1.d * m2.f + m1.f;
                return m;
            },
            args = arguments, i = args.length, m = args[i - 1];

        while (i-- > 1) {
            var m1 = args[i - 1];
            m = multi2(m1, m, this.svg);
        }
        if (Math.abs(m.a) < NEAR_ZERO) m.a = 0;
        if (Math.abs(m.b) < NEAR_ZERO) m.b = 0;
        if (Math.abs(m.c) < NEAR_ZERO) m.c = 0;
        if (Math.abs(m.d) < NEAR_ZERO) m.d = 0;
        if (Math.abs(m.e) < NEAR_ZERO) m.e = 0;
        if (Math.abs(m.f) < NEAR_ZERO) m.f = 0;

        return m;
    }

    // From SVG Edit project
    // Convert a transformation list to a transformation object
    this.transformListToTransform = function (tlist, min, max) {
        var min = min == undefined ? 0 : min;
        var max = max == undefined ? (tlist.numberOfItems - 1) : max;
        min = parseInt(min);
        max = parseInt(max);
        if (min > max) {
            var temp = max;
            max = min;
            min = temp;
        }
        var m = this.svg.root().createSVGMatrix();
        for (var i = min; i <= max; ++i) {
            // if our indices are out of range, just use a harmless identity matrix
            var mtom = (i >= 0 && i < tlist.numberOfItems ?
                tlist.getItem(i).matrix :
                this.svg.root().createSVGMatrix());
            m = this.matrixMultiply(m, mtom);
        }
        return this.svg.root().createSVGTransformFromMatrix(m);
    }

    this.currentTransformation = function (objectID) {
        var oldc_object = this.list[objectID];
        var currentTransformation = oldc_object.object.getAttribute('transform');
        var translationParms = new Array();

        if (currentTransformation !== null) {

            currentTransformation = currentTransformation.replace(/rotate.*?\)/i, "")

            if (currentTransformation.match(/translate/)) {
                var startTranslate = currentTransformation.indexOf("translate");
                var endTranslate = currentTransformation.indexOf(')', startTranslate);
                var translation = currentTransformation.substr(startTranslate + 10, endTranslate - startTranslate - 10);
                translationParms = translation.split(" ");
            } else {
                translationParms[0] = 0;
                translationParms[1] = 0;
            }

            if (currentTransformation.match(/matrix.*/)) {
                translationParms[2] = currentTransformation.replace(/.*matrix/i, "matrix");
            }

        }

        return translationParms;
    }

    // Transform a point by a matrix
    this.transformPoint = function (x, y, m) {
        return {x: m.a * x + m.c * y + m.e, y: m.b * x + m.d * y + m.f};
        var startMatrix = m.indexOf("matrix");
        var endMatrix = m.indexOf(')', startMatrix);
        var m2 = m.substr(startMatrix + 7, endMatrix - startMatrix - 7);
        var matrix = m2.split(", ");

        return {
            x: parseFloat(matrix[0]) * x + parseFloat(matrix[2]) * y + parseFloat(matrix[4]),
            y: parseFloat(matrix[1]) * x + parseFloat(matrix[3]) * y + parseFloat(matrix[5])
        };
    }

    this.getCenterPoint = function (objectID) {

    }

    // From SVG Edit project
    this.setRotationAngle = function (objectID, val) {
        // ensure val is the proper type
        val = parseFloat(val);
        var elem = this.list[objectID].object;
        var bbox = elem.getBBox();
        var cx = bbox.x + bbox.width / 2, cy = bbox.y + bbox.height / 2;
        var tlist = elem.transform.baseVal;

        // only remove the real rotational transform if present (i.e. at index=0)
        if (tlist.numberOfItems > 0) {
            var xform = tlist.getItem(0);
            if (xform.type == 4) {
                tlist.removeItem(0);
            }
        }

        var center = this.transformPoint(cx, cy, this.transformListToTransform(tlist).matrix);
        this.list[objectID].center = Array(center.x, center.y);

        var tlc = this.transformPoint(0, 0, this.transformListToTransform(tlist).matrix);
        var trc = this.transformPoint(bbox.width, 0, this.transformListToTransform(tlist).matrix);
        var blc = this.transformPoint(0, bbox.height, this.transformListToTransform(tlist).matrix);
        //var brc = this.transformPoint(bbox.width, bbox.height, this.transformListToTransform(tlist).matrix);
        this.list[objectID].twidth = Math.round(trc.x - tlc.x);
        this.list[objectID].theight = Math.round(blc.y - tlc.y);

        return 'rotate(' + val + ', ' + center.x + ', ' + center.y + ' ) ' + elem.getAttribute("transform");

    }

    // Transform an object
    this.transform = function (objectID, x, y) {
        x = typeof (x) != 'undefined' ? x : 0;
        y = typeof (y) != 'undefined' ? y : 0;

        var oldc_object = this.list[objectID];

        var translateX = 0;
        var translateY = 0;

        var translationParms = this.currentTransformation(objectID);
        var translateX = parseInt(translationParms[0]);
        var translateY = parseInt(translationParms[1]);

        if (!translateX) translateX = 0;
        if (!translateY) translateY = 0;

        var matrix = "";
        if (translationParms[2]) matrix = translationParms[2];

        var translationString = 'translate(' + (x + translateX) + ' ' + (y + translateY) + ') ';
        var transformString = translationString + ' scale(' + oldc_object.zoomRatio + ') ' + matrix;

        this.svg.change(oldc_object.object, {transform: transformString});

        var rotationString = this.setRotationAngle(objectID, oldc_object.angle);

        if (rotationString)
            transformString = rotationString;

        this.svg.change(oldc_object.object, {transform: transformString});
        //$('#log').val(x+'|'+y+'|'+transformString);

    }

    // sets the selected object ID
    this.select = function (objectID) {
        this.clearSelection();
        this.selectedObjectID = objectID;

        var zoomRatioValue = Math.round(this.list[objectID].zoomRatio * 100) / 100;
        var angleValue = Math.round(this.list[objectID].angle * 100) / 100
        $("#selected_object").html(objectID);
        $("#selected_object").removeClass('warning');
        $("#size_slider").slider("value", zoomRatioValue);
        $("#size_title").html("Size: " + zoomRatioValue);
        $("#angle_slider").slider("value", angleValue);
        $("#angle_title").html("Angle: " + angleValue);
        $(".controls_slider").slider("option", "disabled", false);
        $(".object_control_button").attr("disabled", false);

        //this.updateObjectControlsPosition( objectID );

    }

    this.setSelectedMenuObject = function (objectID) {
        this.selectedMenuObject = objectID;
        svgCanvas.clearSelection();
        svgCanvas.toggleFocus();
    }

    this.clearSelection = function () {
        this.selectedObjectID = null;

        $("#selected_object").html("Please select an object to activate these controls");
        $("#selected_object").toggleClass('warning');
        $(".controls_slider").slider("option", "disabled", true);
        $(".object_control_button").attr("disabled", "disabled");

        this.svg.change(this.svg.getElementById('rotateRight'), {opacity: 0});

    }

    this.setObjectAttribute = function (objectID, key, value) {
        this.list[objectID].object.setAttribute(key, value);
    }

    // stores the SVG canvas
    this.setSVGCanvas = function (svg) {
        this.svg = svg;
    }

    // Bring an object to the background
    this.bringToBack = function (objectID) {
        var element = this.list[objectID].object;
        if (element.previousSibling) {
            element.parentNode.insertBefore(element, element.parentNode.firstChild);
        }

        var grid = this.svg.getElementById('diagram_grid');
        grid.parentNode.insertBefore(grid, grid.parentNode.firstChild);
    }

    // Bring an object to the foreground
    this.bringToFront = function (objectID) {
        var element = this.list[objectID].object;
        element.parentNode.appendChild(element);
    }

    // Toggle the focus on an object (change opacity of non-focused objects)
    this.toggleFocus = function () {
        var objectID = this.selectedObjectID;
        if (objectID) {
            // Focusinga
            this.svg.change(this.list[objectID].object, {opacity: 1});
            this.hasFocusedObject = true;
            for (var listedObjectID in this.list) {
                if (objectID != listedObjectID && this.list[listedObjectID].isAClone) {
                    this.svg.change(this.list[listedObjectID].object, {opacity: unFocusedObjectOpacity});
                }
            }

        } else {
            // Unfocusing
            for (var listedObjectID in this.list) {
                this.svg.change(this.list[listedObjectID].object, {opacity: 1});
                this.hasFocusedObject = false;
            }

        }
    }

    // Remove an object from the canvas
    this.removeObject = function (objectID, force) {
        var force = typeof (force) == "undefined" ? false : force;

        var objectIDsToRemove = new Array();

        if (objectID == "all") {
            objectIDsToRemove = this.list;
        } else {
            actionHistory.clear();
            actionHistory.push(svgCanvas.list[objectID], 'delete');
            objectIDsToRemove[objectID] = true;
        }

        for (var i in objectIDsToRemove) {
            objectIDToRemove = i;
            if (force || this.list[objectIDToRemove].isAClone) {
                this.svg.remove(this.list[objectIDToRemove].object);
                delete this.list[objectIDToRemove];
                if (objectID == "all") this.length--;
            }
        }

        this.clearSelection();
        this.toggleFocus();
    }
    this.historyRemoveObject = function (objectId) {
        this.svg.remove(this.list[objectId].object);
        delete this.list[objectId];
    };

    this.removeIcons = function () {
        for (var i in this.list) {
            if (!this.list[i].isAClone) {
                this.removeObject(i, true);
            }
        }
        currentIconX = 0;
        currentIconY = 600;
    }

    this.iconizeObject = function (objectID) {
        this.setRotationAngle(objectID, 0);
        this.list[objectID].zoomRatio = this.list[objectID].iconZoomRatio;
        this.transform(objectID, this.list[objectID].iconX, this.list[objectID].iconY);
    }

    this.generateSVG = function () {
        return this.toSVG();
    }

    this.duplicate = function (objectID) {
        // Clone the object
        var clone = this.list[objectID].object.cloneNode(true);
        // Add it to the SVG canvas
        this.list[objectID].object.parentNode.appendChild(clone);
        // Add it to the class list
        var cloneObjectID = this.addObject(clone);
        this.list[cloneObjectID].iconId = this.list[objectID].iconId;
        this.list[cloneObjectID].photo = this.list[objectID].photo;
        this.list[cloneObjectID].iconName = this.list[objectID].iconName;
        if (this.list[objectID].isAClone) {
            this.list[cloneObjectID].zoomRatio = this.list[objectID].zoomRatio;
            this.list[cloneObjectID].angle = this.list[objectID].angle;
            this.transform(cloneObjectID, 0, 10);
        } else {
            this.list[cloneObjectID].zoomRatio = this.list[objectID].zoomRatio;
            //this.transform(cloneObjectID, -this.list[objectID].iconX, -300);
        }

        this.list[cloneObjectID].isAClone = true;
        this.select(cloneObjectID);
        this.toggleFocus();

        return clone;
    }

    this.postLoad = function (svg, error) {
        var currentObject = this.svg.getElementById('objectGroup');
        if (currentObject) {
            var objectID = svgCanvas.addObject(currentObject);
            //this.svg.text(currentObject,94.5,391.6,'Amoooss',{"id":objectID+'_text','font-size':24,'color':'red','text-anchor':'start','font-family':'Helvetica, Arial, sans-serif'});
            svgCanvas.setRotationAngle(objectID, 0);
            // var initialZoomRatio = iconizedObjectHeight / svgCanvas.list[objectID].theight;

            var initialZoomRatio ;
            if (svgCanvas.list[objectID].twidth<100) {
                initialZoomRatio = 1;
            }else if (svgCanvas.list[objectID].twidth<180) {
                initialZoomRatio = 80/svgCanvas.list[objectID].twidth;
            }else if (svgCanvas.list[objectID].theight<100) {
                initialZoomRatio = 0.4;
            }else  {
                initialZoomRatio = 0.4;
                // initialZoomRatio = iconizedObjectHeight / svgCanvas.list[objectID].theight;
            }
            var realHeight = svgCanvas.list[objectID].theight * initialZoomRatio;
            if (realHeight > 60) {
                initialZoomRatio = iconizedObjectHeight / svgCanvas.list[objectID].theight;
            }
            var realWidth =  svgCanvas.list[objectID].twidth * initialZoomRatio;
            var kx = Math.round(svgCanvas.list[objectID].twidth * initialZoomRatio)+iconSpacing;
            if (kx < 110) {
                kx = 110
            }
            /*
                        if( (svgCanvas.list[objectID].twidth * initialZoomRatio) < ( iconizedObjectHeight / 3 ) ) {
                            var initialZoomRatio = iconizedObjectWidth / svgCanvas.list[objectID].twidth;
                        }
            */

            svgCanvas.list[objectID].zoomRatio = initialZoomRatio;
            svgCanvas.list[objectID].iconZoomRatio = initialZoomRatio;

            var nextIconX = kx + currentIconX ;
            if (nextIconX >= 600) {
                currentIconX = 0;
                currentIconY += svgCanvas.list[objectID].theight;
                nextIconX = iconSpacing + currentIconX + Math.round(svgCanvas.list[objectID].twidth * initialZoomRatio);
            }
            svgCanvas.transform(objectID, currentIconX, currentIconY);
            svgCanvas.list[objectID].iconX = currentIconX;
            svgCanvas.list[objectID].iconY = currentIconY;
            var position_ = svgCanvas.list[objectID].center;
            svgCanvas.list[objectID].iconId = error.svgObj.id;
            svgCanvas.list[objectID].photo = error.svgObj.photo;
            svgCanvas.list[objectID].iconName = error.svgObj.name;
            var w_ = Math.floor(svgCanvas.list[objectID].width/2);
            $("#view_window").append("<div id='" + objectID + "_text" + "' class='svgText' style='left:" + (position_[0] - 30) + "px;top:" + 680 + "px'>" + error.svgObj.name + "</div>");
            currentIconX = nextIconX;

        }

    }
    this.postLoaded = function (svg, error) {
        var currentObject = this.svg.getElementById('objectGroup');
        if (currentObject) {
            var objectID = svgCanvas.addObject(currentObject);
            var svgObj = error.svgObj
            //this.svg.text(currentObject,94.5,391.6,'Amoooss',{"id":objectID+'_text','font-size':24,'color':'red','text-anchor':'start','font-family':'Helvetica, Arial, sans-serif'});
            svgCanvas.setRotationAngle(objectID, 0);

            svgCanvas.list[objectID].zoomRatio = svgObj.zoomRatio;
            svgCanvas.list[objectID].iconZoomRatio = svgObj.iconZoomRatio;
            svgCanvas.list[objectID].iconX = svgObj.iconX;
            svgCanvas.list[objectID].iconY = svgObj.iconY;
            svgCanvas.list[objectID].photo = svgObj.photo;
            svgCanvas.list[objectID].angle = svgObj.angle;
            svgCanvas.list[objectID].zoomRatio = svgObj.zoomRatio;
            svgCanvas.list[objectID].height = svgObj.height;
            svgCanvas.list[objectID].width = svgObj.width;
            svgCanvas.list[objectID].theight = svgObj.theight;
            svgCanvas.list[objectID].twidth = svgObj.twidth;
            svgCanvas.list[objectID].X = svgObj.X;
            svgCanvas.list[objectID].Y = svgObj.Y;
            svgCanvas.list[objectID].currentX = svgObj.currentX;
            svgCanvas.list[objectID].currentY = svgObj.currentY;
            svgCanvas.list[objectID].center = svgObj.center;
            svgCanvas.list[objectID].iconZoomRatio = svgObj.iconZoomRatio;
            svgCanvas.list[objectID].isAClone = true;
            svgCanvas.transform(objectID, svgObj.center[0], svgObj.center[1]);
            svgCanvas.list[objectID].iconId = svgObj.iconId;
            svgCanvas.list[objectID].parameterId = svgObj.parameterId;
            svgCanvas.list[objectID].photo = svgObj.photo;
            svgCanvas.list[objectID].iconName = svgObj.iconName;
            svgCanvas.transform(objectID, svgObj.center[0] - svgCanvas.list[objectID].center[0], svgObj.center[1] - svgCanvas.list[objectID].center[1]);
            svgCanvas.list[objectID].center = svgObj.center;
        }

    }
    this.loadPage = function(type,pageNo){
        page.gotoPage(pageNo);
        if(!this.loadObjectList_){
            this.loadObjectList_ = loadObjectList_;
        }
        this.loadObjectList_( null, null, type);
    }
    var loadObjectList_ = function (svg, error, type,initParam) {

        if (this.svg == null) this.svg = svg;

        svgCanvas.removeIcons();
        $(".svgText").remove();

        var objectList = new Array();
        if (icons && icons[type]) {
            icons[type].forEach(function (obj) {
                objectList.push(obj);
            })
        }

        for (var i in objectList) {
            console.log(i);
            if (i < page.beginNo()) {
                continue;
            }
            if (i > page.endNo()) {
                break;
            }

            // (function(){})();
            this.svg.load(utils.domain + objectList[i].photo, {
                addTo: true,
                svgObj: objectList[i],
                onLoad: svgCanvas.postLoad
            });
        }
        if (initParam && parameters) {
            parameters.forEach(function (parameter) {
                var _obj = JSON.parse(parameter.svgInfo);
                _obj.parameterId = parameter.id;
                _obj.iconId = parameter.iconId;
                svgCanvas.loadObjects(_obj);

            }.bind(this));
        }
    };
    this.loadObjectList = function (svg, error, type) {
        type = type || 'Backgrounds';
        page.init();
        if (icons && icons[type]) {
            page.calPageNo(icons[type].length);
        }
        if(!this.loadObjectList_){
            this.loadObjectList_ = loadObjectList_;
        }
        this.loadObjectList_( svg, error, type,true);
    };
    this.loadObjectListByOption = function (type) {
        page.init();
        if (icons && icons[type]) {
            page.calPageNo(icons[type].length);
        }
        if(!this.loadObjectList_){
            this.loadObjectList_ = loadObjectList_;
        }
        this.loadObjectList_( null, null, type);
    };
    this.loadObjects = function(_obj){
        if (_obj.iconId) {
            this.svg.load(utils.domain + _obj.photo, {addTo: true, svgObj: _obj, onLoad: svgCanvas.postLoaded});
        } else {
            var currentLineGroup = svgCanvas.svg.group({stroke: 'red', strokeWidth: 1});
            svgCanvas.addLineObject(currentLineGroup,lineType);
            if (_obj.iconName == 'arrow') {
                var defs = svgCanvas.svg.defs('arrowDef');
                var marker = svgCanvas.svg.marker(defs, 'arrowMarker', 5, 5, 10, 10,'auto-start-reverse',{stroke:"#020102", fill:"#020102"});
                var arrowPath = svgCanvas.svg.createPath();
                svgCanvas.svg.path(marker, arrowPath.move(0, 0).line(10,5).line(0,10).close());
            }
            var path = svgCanvas.svg.createPath();
            if (_obj.iconName == 'arrow') {
                svgCanvas.svg.path(currentLineGroup, path.move(_obj.left_x, _obj.left_y).line(_obj.right_x,_obj.right_y),
                    {fill: 'none', stroke: '#020102', strokeWidth: 2,id:'path_'+currentLineGroup.id,"marker-end":"url(#arrowMarker)"});
            }else{
                svgCanvas.svg.path(currentLineGroup, path.move(_obj.left_x, _obj.left_y).line(_obj.right_x,_obj.right_y),
                    {fill: 'none', stroke: '#020102', strokeWidth: 2,id:'path_'+currentLineGroup.id});
            }
            var texts = svgCanvas.svg.createText();
            var text = svgCanvas.svg.text(currentLineGroup,'');

            svgCanvas.svg.textpath(text, '#path_'+currentLineGroup.id, texts.string(_obj.memo),{startOffset:'20%',strokeWidth:0.5,stroke:'red'});
            svgCanvas.list[currentLineGroup.id].left_x = _obj.left_x ;
            svgCanvas.list[currentLineGroup.id].left_y = _obj.left_y ;
            svgCanvas.list[currentLineGroup.id].right_x = _obj.right_x ;
            svgCanvas.list[currentLineGroup.id].right_y = _obj.right_y ;
            svgCanvas.list[currentLineGroup.id].memo = _obj.memo ;
        }
    };
    this.loadObjectList_prev = function (svg, error, type) {

        if (this.svg == null) this.svg = svg;

        svgCanvas.removeIcons();

        var objectList = new Array();

        switch (type) {
            case 'strobes':
                objectList.push(
                    './svg/sub39.svg',
                    './svg/sub43.svg',
                    './svg/sub38.svg',
                    './svg/sub48.svg',
                    './svg/sub19.svg',
                    './svg/sub2.svg',
                    './svg/sub42.svg',
                    './svg/sub40.svg',
                    './svg/sub52.svg'
                );
                break;

            case 'speedlights':
                objectList.push(
                    './svg/sub63.svg',
                    './svg/sub64.svg'
                );
                break;

            case 'beautydishes':
                objectList.push(
                    './svg/sub53.svg',
                    './svg/sub56.svg',
                    './svg/sub55.svg'
                );
                break;

            case 'lightmodifiers':
                objectList.push(
                    './svg/sub0.svg',
                    './svg/sub45.svg',
                    './svg/sub18.svg',
                    './svg/sub1.svg'
                );
                break;

            case 'diffusers':
                objectList.push(
                    './svg/sub5.svg',
                    './svg/sub6.svg',
                    './svg/sub4.svg',
                    './svg/sub3.svg'
                );
                break;

            case 'panels':
                objectList.push(
//				'./svg/sub7.svg',
//				'./svg/sub24.svg',
                    './svg/sub10.svg',
//				'./svg/sub33.svg',
//				'./svg/sub34.svg',
                    './svg/sub25.svg'
//				'./svg/sub32.svg',
//				'./svg/sub8.svg',
//				'./svg/sub26.svg'
//				'./svg/sub41.svg',
//				'./svg/sub27.svg'
//				'./svg/sub9.svg'
                );
                break;

            case 'vcards':
                objectList.push(
                    './svg/sub12.svg',
                    './svg/sub31.svg',
                    './svg/sub29.svg',
                    './svg/sub14.svg',
                    './svg/sub11.svg',
                    './svg/sub28.svg',
                    './svg/sub30.svg',
                    './svg/sub13.svg'
                );
                break;

            case 'subjects':
                objectList.push(
                    './svg/sub47.svg',
                    './svg/sub62.svg'
                );
                break;

            case 'cameras':
                objectList.push(
                    './svg/sub44.svg'
                );
                break;

            case 'softboxes':
                objectList.push(
                    './svg/sub51.svg',
                    './svg/sub61.svg',
                    './svg/sub57.svg',
                    './svg/sub49.svg',
                    './svg/sub60.svg',
                    './svg/sub65.svg',
                    './svg/sub54.svg',
                    //'./svg/sub59.svg',
                    './svg/sub50.svg',
                    './svg/sub58.svg'
                );
                break;

            case 'otherlight':
                objectList.push(
                    './svg/sub46.svg',
                    './svg/sub66.svg'
                );
                break;
            case 'test':
                objectList.push(
                    './svg/sub301.svg',
                    './svg/sub302.svg',
                    './svg/sub303.svg',
                    './svg/sub304.svg',
                    './svg/sub305.svg',
                    './svg/sub306.svg'
                );
                break;

            case 'backdrops':
            default:
                objectList.push(
                    './svg/sub16.svg',
                    './svg/sub17.svg'
                );
                break;

        }

        for (var i in objectList) {
            this.svg.load(objectList[i], {addTo: true, onLoad: svgCanvas.postLoad});
        }


    }

}

